<html>
<head><meta charset="utf-8"><title>Getting machine-readable output from Clippy? · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20machine-readable.20output.20from.20Clippy.3F.html">Getting machine-readable output from Clippy?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="246513291"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20machine-readable%20output%20from%20Clippy%3F/near/246513291" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Lijin <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20machine-readable.20output.20from.20Clippy.3F.html#246513291">(Jul 19 2021 at 21:00)</a>:</h4>
<p>Does clippy support something like <code>--emit=json</code>? Wondering if there's a way to expose <code>rustc_ast::ast::Item.span</code> and other metadata about linter findings</p>



<a name="246523884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20machine-readable%20output%20from%20Clippy%3F/near/246523884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20machine-readable.20output.20from.20Clippy.3F.html#246523884">(Jul 19 2021 at 22:35)</a>:</h4>
<p>You can get the span with --error-format json I think</p>



<a name="246523903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20machine-readable%20output%20from%20Clippy%3F/near/246523903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20machine-readable.20output.20from.20Clippy.3F.html#246523903">(Jul 19 2021 at 22:35)</a>:</h4>
<p>I don't know what other "linter findings" you're referring to</p>



<a name="246541430"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20machine-readable%20output%20from%20Clippy%3F/near/246541430" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Lijin <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20machine-readable.20output.20from.20Clippy.3F.html#246541430">(Jul 20 2021 at 03:33)</a>:</h4>
<p>Hmm... </p>
<div class="codehilite"><pre><span></span><code>sxlijin@sxlijin2-devbox:2021-07-20T03:30:43+00:00:~/ripgrep (master) [101]
$ cargo clippy --output-format=json
++ 2021-07-20T03:30:47+00:00 ++ cargo clippy --output-format=json
error: Found argument &#39;--output-format&#39; which wasn&#39;t expected, or isn&#39;t valid in this context

USAGE:
    cargo check [OPTIONS]

For more information try --help
sxlijin@sxlijin2-devbox:2021-07-20T03:30:48+00:00:~/ripgrep (master) [1]
$ cargo clippy --version
++ 2021-07-20T03:30:53+00:00 ++ cargo clippy --version
clippy 0.1.55 (014026d 2021-07-19)
sxlijin@sxlijin2-devbox:2021-07-20T03:30:53+00:00:~/ripgrep (master) [0]
$ uname -a
++ 2021-07-20T03:30:54+00:00 ++ uname -a
Linux sxlijin2-devbox 5.8.0-1036-azure #38~20.04.1-Ubuntu SMP Thu Jun 17 14:14:18 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
</code></pre></div>



<a name="246541574"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/Getting%20machine-readable%20output%20from%20Clippy%3F/near/246541574" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sam Lijin <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/Getting.20machine-readable.20output.20from.20Clippy.3F.html#246541574">(Jul 20 2021 at 03:36)</a>:</h4>
<p>ah, the flag is <code>--message-format</code>: <a href="https://github.com/rust-lang/rust-clippy/blob/95c2ab75db80e33b687531de17b865a7988212c3/lintcheck/src/main.rs#L265">https://github.com/rust-lang/rust-clippy/blob/95c2ab75db80e33b687531de17b865a7988212c3/lintcheck/src/main.rs#L265</a></p>
<p>thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>